'use strict';
// 规格组表
module.exports = app => {
  const { STRING, BIGINT } = app.Sequelize;

  const MallSpecGroup = app.model.define('mall_spec_group', {
    category_id: {
      type: BIGINT,
      allowNull: false,
      comment: '类目的ID，规格组属于哪个类目下',
    },
    name: {
      type: STRING,
      allowNull: false,
      comment: '规格组名称',
    },
  });

  MallSpecGroup.associate = () => {
    // 存在多对一关系，所以使用belongsTo()
    MallSpecGroup.associate = () => {
      app.model.MallSpecGroup.belongsTo(app.model.MallCategory, { foreignKey: 'category_id' });
    };
  };
  return MallSpecGroup;
};
